using UnityEngine;
using System.Collections;

public class SplashScreen : MonoBehaviour
{
	public Texture backgroundTexture;
	private static float splashWaitTime = 3.0f;
	public int counter = 0;

	void Start()
	{
		// for callback return
		counter = 10;
		InvokeRepeating("Foo", 0, 0);
	}

	void OnGUI()
	{
		// Draw our texture on screen - full screen
		GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), backgroundTexture);

		// Call coroutine to hold splash screen up for a given amount of time
		StartCoroutine(SplashHold());
	}

	IEnumerator SplashHold()
	{
		yield return new WaitForSeconds(splashWaitTime);
		//Application.LoadLevel("MenuScreen");
	}

	void Foo()
	{
		// do stuff
		if (--counter == 0)
			CancelInvoke("Foo");
	}

}
